blob: d26c51d4eb343fea55ff98bafe0ece7e444beb81 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
---
import FormField from '@/components/FormField.astro'
import { FORM_POST_URL } from '@/consts'
import Layout from '@/layouts/Layout.astro'
import { getAllForms } from '@/lib/data-utils'
import { formatDate } from '@/lib/utils'
import { render } from 'astro:content'
export async function getStaticPaths() {
const forms = await getAllForms()
return forms.map((form) => ({
params: { id: form.id },
props: form,
}))
}
const { Content } = await render(Astro.props)
const form = Astro.props.data
const fields = Astro.props.data.form.fields
---
<Layout>
<section
class="border-border mx-auto flex w-full max-w-3xl flex-col items-center gap-y-2 rounded-xl border p-8"
>
<h1
class="mb-2 w-full scroll-mt-31 text-center text-3xl leading-tight font-medium sm:text-4xl"
>
{form.title}
</h1>
<div
class="text-muted-foreground mb-4 mb-6 flex w-fit py-2 text-xs sm:px-2 sm:py-0 sm:text-sm"
>
<span>{formatDate(form.date)}</span>
</div>
<article class="prose w-full">
<Content />
</article>
<form
action={`${FORM_POST_URL}${form.id}`}
method="POST"
class="flex w-full flex-col items-start gap-12"
>
{fields.map((field) => <FormField field={field} />)}
<div class="flex w-full justify-end">
<button
type="submit"
class="bg-primary text-primary-foreground rounded-lg px-4 py-2 font-sans text-lg font-bold"
>{form.submit_text || 'Submit'}</button
>
</div>
</form>
</section>
</Layout>
|